package pro.cherish.knowledgerabbitmqproducer.web;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import pro.cherish.knowledgerabbitmqproducer.config.BeanConfig;
import pro.cherish.knowledgerabbitmqproducer.config.QueueConfig;

/**
 * @author 创建人：lys
 * @version 版本号：V1.0
 * <p>
 * ***************************修订记录************************************
 * 2020-3-22 lys 创建该类功能。
 * **********************************************************************
 * </p>
 * @ClassName 类名：TestController
 * @Description 功能说明：
 * <p>
 * TODO
 * </p>
 * **********************************************************************
 * @date 创建日期： 2020-3-22
 */
@RestController
public class TestController {
    @Autowired
    private RabbitTemplate rabbitTemplate;

    @GetMapping("/send")
    public Object test01() throws InterruptedException {
        for (int i = 0; i < 30; i++) {
            rabbitTemplate.convertAndSend(QueueConfig.CHERISH_TOPIC_EXCHANGE, QueueConfig.CHERISH_ROUTE_KEY, "hello world");
            Thread.sleep(500);
        }
        return true;
    }

    @Autowired
    private BeanConfig.B b;

    @Autowired
    private BeanConfig.C c;

    @GetMapping("/testBean")
    public Object testBean() throws InterruptedException {
        System.out.println("B对象"+b);
        System.out.println("C对象"+c);
        return true;
    }
}
